//
//  KPBaseViewController.swift
//  KPBaseProject
//
//  Created by Kipp Dev on 2018/3/21.
//  Copyright © 2018年 Kipp. All rights reserved.
//

import UIKit
import RxSwift
import RxCocoa
import TangramKit
import Material

class KPBaseViewController: UIViewController {

    let bag = DisposeBag()
    override func viewDidLoad() {
        super.viewDidLoad()
        config()
    }

    // MARK: - 基类配置
    func config() {
        view.backgroundColor = #colorLiteral(red: 0.9490196078, green: 0.9490196078, blue: 0.9490196078, alpha: 1)
        kp_setNavigationBarColor(color: UIColor.Material.white, tintColor: UIColor.Material.black)
    }

    public func showAlertView(title:String, content:String) {
        let alert = UIAlertController.init(title: title, message: content, preferredStyle: UIAlertControllerStyle.alert)
        self.present(alert, animated: true, completion: nil)
        self.perform(#selector(dismiss(animated:completion:)), with: alert, afterDelay: 0.75)
    }

    fileprivate func dismissAlert(alert: UIAlertController) {
        alert.dismiss(animated: true, completion: nil)
    }

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .default
    }

    override func setNeedsStatusBarAppearanceUpdate() {
        super.setNeedsStatusBarAppearanceUpdate()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }

    override func rt_customBackItem(withTarget target: Any!, action: Selector!) -> UIBarButtonItem! {
        return UIBarButtonItem.init(image: #imageLiteral(resourceName: "返回"), style: .plain, target: target, action: action)
    }

}

